// Node.cpp	-	Node class
// Stores and returns information pertaining to a node on a graph.
// Stores: Point name, X,Y position, pointers to connected Nodes.
// Returns: Point name, X,Y position, vector<Node*> of connected Nodes,
// iterator to vector<Node*> of connected Nodes.

#include <iostream>
#include "Node.h"

Node::Node(void) : name(""), x(0), y(0), f(-1), open(false), closed(false)
{
}

Node::Node(std::string newName, int pointX, int pointY) :
	name(newName), x(pointX), y(pointY), f(-1), open(false), closed(false)
{
}

Node::~Node(void)
{
}

std::string Node::getName(void) const
{
	return name;
}

int Node::getX(void) const
{
	return x;
}

int Node::getY(void) const
{
	return y;
}

Node* Node::getParent(void) const
{
	return parent;
}

int Node::getF(void) const
{
	return f;
}

std::vector<Node*> Node::getConnections(void) const
{
	return connections;
}

void Node::addConnection(Node *newConnection)
{
	connections.push_back(newConnection);
}

void Node::setParent(Node* p)
{
	parent = p;
}

void Node::setF(int fValue)
{
	f = fValue;
}

void Node::print(void) const
{
	std::cout << "Name:\t" << name <<
		"\nX:\t" << x <<
		"\nY:\t" << y <<
		"\nConnections:\t";
	for (size_t i = 0; i < connections.size(); ++i)
	{
		std::cout << connections.at(i)->getName() << " ";
	}
	std::cout << std::endl;
}

void Node::inOpenList(bool value)
{
	open = value;
}

bool Node::inOpenList(void) const
{
	return open;
}

void Node::inClosedList(bool value)
{
	closed = value;
}

bool Node::inClosedList(void) const
{
	return closed;
}
